signature REGALLOC =
sig
	structure Frame : FRAME

	type allocation = Frame.register Temp.Table.table

	val alloc : Assem.instr list * Frame.frame -> Assem.instr list * allocation
end

structure RegAlloc : REGALLOC =
struct
  structure C = Color
  structure F = MipsFrame
  structure L = Liveness
  structure MB = Temp.Table
  structure W = MakeGraph

  type allocation = F.register MB.table
	
  fun alloc (instrs, frame) =
      let val (fg, fnodes) = W.instrs2graph instrs
	  val (ig, liveTemps) = L.interferenceGraph (fg, fnodes)
	  val (colors, tempList) = C.color {interference=ig,
					    initial=F.tempMap,
					    spillCost=(fn _ => 1),
					    registers=F.registers}
      in (instrs, colors)
      end

  structure Frame = F
end
